###########################################################################################
###########################################################################################
### THIS IS A README FILE FOR FAULT BENCHMARK OF SMALL SCALE AES                        ###
### I.E. FOR THE FILES: "AES-n-r-c-w_fault_polys.txt" and "AES-n-r-c-w_fault_CNF.txt"   ### 
###########################################################################################
###########################################################################################

r = # rows in the state matrix
c = # columns in the state matrix
w = # bits in the word 
Fault attacks does not depend on #rounds (suppose #rounds > 2).

Small scale AES fault equations over GF(16) resp. GF(256) have the following shapes 
(both for the 4/8 bit version): 

d     ... fault parameter
x     ... correct ciphertext
x'    ... faulty ciphertext (named as well as y in the following text)
k     ... parts of the key from the last round
S(-1) ... inversion of S Box
*     ... multiplications in GF(16) resp. GF(256)

RC=11:

d1 = S(-1)(x1 + k1) + S(-1)(x'1 + k1)

RC=12:

d1 = S(-1)(x1 + k1) + S(-1)(x'1 + k1)
d2 = S(-1)(x2 + k2) + S(-1)(x'2 + k2)

RC=14:

d1 = S(-1)(x1 + k1) + S(-1)(x'1 + k1)
d2 = S(-1)(x2 + k2) + S(-1)(x'2 + k2)
d3 = S(-1)(x3 + k3) + S(-1)(x'3 + k3)
d4 = S(-1)(x4 + k4) + S(-1)(x'4 + k4)

RC=21:

3*d1 = S(-1)(x1 + k1) + S(-1)(x'1 + k1)
2*d1 = S(-1)(x2 + k2) + S(-1)(x'2 + k2)

RC=22:

3*d1 = S(-1)(x1 + k1) + S(-1)(x'1 + k1)
2*d1 = S(-1)(x4 + k4) + S(-1)(x'4 + k4)

2*d2 = S(-1)(x3 + k3) + S(-1)(x'3 + k3)
3*d2 = S(-1)(x2 + k2) + S(-1)(x'2 + k2)

RC=24:

3*d1 = S(-1)(x1 + k1) + S(-1)(x'1 + k1)
2*d1 = S(-1)(x8 + k8) + S(-1)(x'8 + k8)
2*d2 = S(-1)(x7 + k7) + S(-1)(x'7 + k7)
3*d2 = S(-1)(x6 + k6) + S(-1)(x'6 + k6)

3*d3 = S(-1)(x5 + k5) + S(-1)(x'5 + k5)
2*d3 = S(-1)(x4 + k4) + S(-1)(x'4 + k4)
2*d4 = S(-1)(x3 + k3) + S(-1)(x'3 + k3)
3*d4 = S(-1)(x2 + k2) + S(-1)(x'2 + k2)

RC=41:

2*d1 = S(-1)(x1 + k1) + S(-1)(x'1 + k1)
d1 = S(-1)(x2 + k2) + S(-1)(x'2 + k2)
d1 = S(-1)(x3 + k3) + S(-1)(x'3 + k3)
3*d1 = S(-1)(x4 + k4) + S(-1)(x'4 + k4)

RC=42:

2*d1 = S(-1)(x1 + k1) + S(-1)(x'1 + k1)
d1 = S(-1)(x6 + k6) + S(-1)(x'6 + k6)
d1 = S(-1)(x3 + k3) + S(-1)(x'3 + k3)
3*d1 = S(-1)(x8 + k8) + S(-1)(x'8 + k8)

2*d2 = S(-1)(x5 + k5) + S(-1)(x'5 + k5)
d2 = S(-1)(x2 + k2) + S(-1)(x'2 + k2)
d2 = S(-1)(x7 + k7) + S(-1)(x'7 + k7)
3*d2 = S(-1)(x4 + k4) + S(-1)(x'4 + k4)

RC=44:

2*d1 = S(-1)(x1 + k1) + S(-1)(x′1 + k1)
d1 = S(-1)(x14 + k14) + S(-1)(x′14 + k14)
d1 = S(-1)(x11 + k11) + S(-1)(x′11 + k11)
3*d1 = S(-1)(x8 + k8) + S(-1)(x′8 + k8)

3*d2 = S(-1)(x5 + k5) + S(-1)(x′5 + k5)
2*d2 = S(-1)(x2 + k2) + S(-1)(x′2 + k2)
d2 = S(-1)(x15 + k15) + S(-1)(x′15 + k15)
d2 = S(-1)(x12 + k12) + S(-1)(x′12 + k12)

d3 = S(-1)(x9 + k9) + S(-1)(x′9 + k9)
3*d3 = S(-1)(x6 + k6) + S(-1)(x′6 + k6)
2*d3 = S(-1)(x3 + k3) + S(-1)(x′3 + k3)
d3 = S(-1)(x16 + k16) + S(-1)(x′16 + k16)

d4 = S(-1)(x13 + k13) + S(-1)(x′13 + k13)
d4 = S(-1)(x10 + k10) + S(-1)(x′10 + k10)
3*d4 = S(-1)(x7 + k7) + S(-1)(x′7 + k7)
2*d4 = S(-1)(x4 + k4) + S(-1)(x′4 + k4) 


These equations are rewritten to Boolean polynomial equations ("AES-n-r-c-w_fault_polys.txt") 
and converted to CNF clauses ("AES-n-r-c-w_fault_CNF.txt") as well. 

Example:

For the 4 bit version and the equations

(0 eq.) 3*d1 = S(-1)(x1 + k1) + S(-1)(x'1 + k1)
(1 eq.) 2*d2 = S(-1)(x2 + k2) + S(-1)(x'2 + k2)
(2 eq.) ...

we introduce these new variables (assuming that y = x' for better readability):

d00,d01,d02,d03,x00,x01,x02,x03,y00,y01,y02,y03,k00,k01,k02,k03
d10,d11,d12,d13,x10,x11,x12,x13,y10,y11,y12,y13,k10,k11,k12,k13

The variable Vij represent j-th (bit) variable of the variable V in i-th equation (the order is fixed as above), 
where V ={d,x,y,k}. The same numbering of the variables holds for the 8 bit version. When the left sides are 
the same as in this example:

3*d1 = S(-1)(x1 + k1) + S(-1)(x'1 + k1)
2*d1 = S(-1)(x2 + k2) + S(-1)(x'2 + k2)

we introduce only d00,d01,d02,d03 for the parameter d1.

For w bit version and k equations we create w*k Boolean polynomial equations. 
The given equations can be modified further to meet specific criteria of the solver 
(e.g. via introducing (and substituting) new variables for some terms which results in reducing the degree 
and extending the number of equations). Moreover,the fault equation structure can be read off from resulting polynomials. 
The terms containing x__ come form the first S(-1) and terms containing y__ come from the second S(-1). 
The correspondence between variables in the polynomials and their CNF representation is documented in the comment section
of each "AES-n-r-c-w_fault_CNF.txt" file.




